package cn.net.yugu.doraemon.springweb.accesslog;

public class AccessLogHolder {

    public final static ThreadLocal<AccessLog> REQUEST_HOLDER = new ThreadLocal<AccessLog>();

    public static void set(AccessLog log) {
        REQUEST_HOLDER.set(log);
    }

    public static AccessLog get() {
        AccessLog accessLog = AccessLogHolder.REQUEST_HOLDER.get();
        if (accessLog == null) {
            accessLog = new AccessLog();
            AccessLogHolder.REQUEST_HOLDER.set(accessLog);
        }
        return accessLog;
    }

    public static void clear() {
        REQUEST_HOLDER.set(null);
    }
}
